
$(document).ready(function(){
    //var vConsole = new VConsole();  //手机调试
    $.toast.prototype.defaults.duration=1600;

     // var html= $('html');
     //   var hW = html.outerWidth() > 640 ? 640 : html.outerWidth();
     //     _rem = hW/10;
     //     html.css('fontSize',_r);
     //     $(function() {
     //         FastClick.attach(document.body);
     //     });


//支付宝防复制，测试dealername乱码，ios设置密码按钮**，按钮特效,倒计时功能，开箱按钮调整,一键退柜页面显示已退柜,取开箱离线提示
    //设置密码输入优化，一键退柜优化，
// 手机验证码登录?
//支付，付费免费创建订单同一个*,新退款接口，开箱流程说明书展示 ，一键退柜当天已经退的也显示，按钮禁点,
    //一键退柜成功一个加载按钮就消失了


    OPENID      =  getUrlParam('openid');
    TERMINALID  =  getUrlParam('terminalid');
    SEXAREA     =  getUrlParam('sex');
    FLAG        =  getUrlParam('flag');
    DEALERNAME  =  decodeURI(getUrlParam("dealerName"),"utf-8");
    TERMINALNAME=  getUrlParam('terminalName');

    if(FLAG==1){
        $('.goback').css('display',"block");
    }
    if(TERMINALID!="1"){
    	FLAG = 2;
    	SEXAREA = 1;
    }
    console.log(OPENID,TERMINALID,SEXAREA,FLAG,DEALERNAME,TERMINALNAME);
    var resMsg;
    $.showLoading("请稍等...");

    $.ajax({
        type: 'GET',
        dataType: 'json',
        async:false,
        url: '../../../storeControles',
        data: {"terminalid":    TERMINALID,
            "openid":        OPENID,
            "terminalname": TERMINALNAME,
            "dealername":   DEALERNAME,
            "timestamp":     "1000",
            "flag":          FLAG ,
            "sex":            SEXAREA ,
            "types": "loadHomePage"},      // 清除预订单
        contentType: 'application/x-www-form-urlencoded',
        success: function(res){
            console.log(res);

                resMsg=res;

        }
    });
    console.log(resMsg);
            if(resMsg.err_code =="0"){ // 返回成功
                $.hideLoading();
                if (resMsg.data.displaySign == 'stores'){
                    if (resMsg.data.storeList.length > 0){
                        var prepaymenttype=resMsg.data.storeList[0].prepaymenttype; //收费模式
                        PREPAYMENTTYPE =prepaymenttype;
                        console.log(PREPAYMENTTYPE);
                        if(PREPAYMENTTYPE!=0){
                            $('.pay-money>div').css({'fontSize':'0.35rem'});
                        }
                        var list = resMsg.data.storeList;
                        var str = list[0].remark;

                        var arrstr=getCharges(list[0].remark);
                        var allPrice=[];
                         // console.log(arr)
                        $.each(arrstr,function(i,n){  //把租金放到数组
                            allPrice.push(Number(n.split('分')[0])/100);
                        });
                        var depPrice=[],rentPrice=[]; //押金，租金
                        for (var i = 0; i <allPrice.length ; i++) {
                            if(i%2==0){
                                rentPrice.push(allPrice[i]) //租金数组
                            }else{
                                depPrice.push(allPrice[i])   //押金数组
                            }
                        }
                        var  company='';
                        if(list[0].prepaymenttype=='0'){
                            console.log('此为免费模式，不能截取');
                        }else{
                            console.log('收费模式，截取出单位天或者时');
                            company=str.substr(-2,1);
                            $('.storeCompany').html('/ '+company);
                        }
                        if (list[0].lsnumber>0){
                            if(prepaymenttype=='0'){ //如果是免费模式
                                 $("#msupsmall").text(list[0].lsnumber);
                            	 $("#supSmDep").attr('data-dep',0);
                            	 $("#supSmRent").attr("data-rent",0);
                            }else{
                                 $("#msupsmall").text(list[0].lsnumber);
                                 $("#supSmDep").attr('data-dep',depPrice[0]); //把获取的押金放入页面
                                 $("#supSmRent").attr("data-rent",rentPrice[0]);
                            }
                        }else{//
                        	$("#supsm-card").css('display','none');  //或  没有剩余的不再显示 display:none
                        	$("#msupsmall").text(0);//如果超小箱没有剩余，就把0放入页面
                        }
                        if (list[0].snumber>0){//  || s.length>0
                        	 if(prepaymenttype=='0'){ //如果是免费模式
                                 $("#msmall").text(list[0].snumber);//可用数量
                                 $("#smRent").attr("data-rent",0);
                                 $("#smDep").attr("data-dep",0);  //押金
                            }else{
                                 $("#msmall").text(list[0].snumber);//可用数量
                                 $("#smDep").attr("data-dep",depPrice[1]);  //押金
                                 $("#smRent").attr("data-rent",rentPrice[1]);
                            }
                        }else{
                        	$("#sm-card").css('display','none');
                        	$("#msmall").text(0);
                        }
                        if (list[0].mnumber>0){//2
                        	 if(prepaymenttype=='0'){ //如果是免费模式
                                 $("#mmiddle").text(list[0].mnumber);//可用数量
                        		 $("#midDep").attr("data-dep",0);  //押金
                                 $("#midRent").attr("data-rent",0);
                        	 }else{
                                 $("#mmiddle").text(list[0].mnumber);//可用数量
                                 $("#midDep").attr("data-dep",depPrice[2]);  //押金
                                 $("#midRent").attr("data-rent",rentPrice[2]);
                        	 }
                        }else{

                        	$("#mid-card").css('display','none');
                        	$("#mmiddle").text(0);
                        }


                        if (list[0].lnumber>0){//3
                             if(prepaymenttype=='0'){ //如果是免费模式

                                  $("#mbig").text(list[0].lnumber);

                            	  $("#bigDep").attr("data-dep",0);  //押金
                                  $("#bigRent").attr("data-rent",0);
                          }else{
                                 $("#mbig").text(list[0].lnumber);
                                  $("#bigDep").attr("data-dep",depPrice[3]);  //押金
                                  $("#bigRent").attr("data-rent",rentPrice[3]);
                             }
                        }else{//

                        	 $("#big-card").css('display','none');
                        	 $("#mbig").text(0);
                        }
                        if (list[0].llnumber>0){//4
                        	 if(prepaymenttype=='0'){
                                 $("#msupbig").text(list[0].llnumber);
                        		 $("#supBigDep").attr("data-dep",0);  //押金
                                 $("#supBigRent").attr("data-rent",0);
                        	 }else{
                        	     $("#msupbig").text(list[0].llnumber);
                                 $("#supBigDep").attr("data-dep",depPrice[4]);  //押金
                                 $("#supBigRent").attr("data-rent",rentPrice[4]);
                        	 }
                        }else{
                        	 $("#supbig-card").css('display','none');
                        	 $("#msupbig").text(0);
                        }

                      //新的
                        var  MIN = 0;

                        var deparr=[],rentarr=[];
                        $(".reserve-num").val(0);//解决问题：从其他页面返回时，选择的数量值不会清空，但是押金，租金都会清空

                        $('.weui-count__decrease').click(function (e) {  //减

                        	var $input = $(e.currentTarget).parent().find('.weui-count__number');
                        	var number = parseInt($input.val() || "0") - 1;
                        	if(number < MIN) number = MIN;
                        	$input.val(number);
                          	//单押金
                      		var decDep=Number($(e.currentTarget).parent().parent().next().children().eq(0).children().eq(1).attr("data-dep"));
                      		//把计算好的押金放入标签中,
                      		$(e.currentTarget).parent().parent().next().children().eq(0).children()[1].innerHTML=decDep*Number(number);

                      		//单租金
                      		var rent=Number($(e.currentTarget).parent().parent().next().children().eq(1).children().eq(1).attr("data-rent"));
                            //把计算好的租金放入标签中
                      		$(e.currentTarget).parent().parent().next().children().eq(1).children()[1].innerHTML=rent*Number(number);//把计算好的组金放入标签中,

                        	//押金数组，计算和
                        	deparr=[],rentarr=[];
                        	$(".dep").each(function(i){
                        			//console.log($(this)[0].innerHTML);
                        		deparr.push($(this)[0].innerHTML);
                        	});
                        	//计算押金和，把总计值放入标签中
                        	var depsum=0;
                        	for(var i=0;i<deparr.length;i++){depsum+=Number(deparr[i]);}
                        	//$(".all-price").html(depsum);

                        	//租金
                        	$(".rent").each(function(i){rentarr.push($(this)[0].innerHTML.replace(/(^\s*)|(\s*$)/g,""));});
                        	//计算租金和
                        	var rentsum=0;
                        	for(var i=0;i<rentarr.length;i++){rentsum+=Number(rentarr[i]);}
                        	var totalPrice=Number(depsum+rentsum).toFixed(2);
                        		//把总数放入标签中
                        	$(".all-price").html(totalPrice);
                        });

                        $('.weui-count__increase').click(function (e) {  //加
                        		var $input = $(e.currentTarget).parent().find('.weui-count__number');
                        		var number = parseInt($input.val() || "0") + 1;
                        		//startnum --可用的箱子数量
                        		var startnum=$(e.currentTarget).parent().parent().parent().parent().parent().prev().children().eq(1).children()[0].innerHTML;
                         		if(number>startnum){
                         			$.toast("对不起，数量不能超过可用数量",'text');
                         			number=startnum;
                         		}else{ //限定用户最多能选择几个
                                    var closedNum=0; //用户选的所以箱子数量之和
                                    $('.reserve-num').each(function () {
                                        closedNum+=Number($(this).val());
                                    });
                                    closedNum++;
                                    if(closedNum>list[0].availableNumber || number>list[0].availableNumber){
                                        if(list[0].availableNumber==0){
                                            $.toast("对不起，您已达到租箱上限",'text');
                                        }else{
                                            $.toast("此柜限定每人最多选择"+list[0].availableNumber+"个",'text');
                                        }
                                        number=number-1;
                                    }

                                    $input.val(number);
                                }


                                //单押金
                        		var incDep=Number($(e.currentTarget).parent().parent().next().children().eq(0).children().eq(1).attr("data-dep"));

                        		//把计算好的押金放入标签中,
                        		$(e.currentTarget).parent().parent().next().children().eq(0).children()[1].innerHTML=incDep*Number(number);
                        		//单租金
                        		var rent=Number($(e.currentTarget).parent().parent().next().children().eq(1).children().eq(1).attr("data-rent"));
                        		//把计算好的租金放入标签中,
                        		$(e.currentTarget).parent().parent().next().children().eq(1).children()[1].innerHTML=rent*Number(number);


                        		//押金数组
                        		deparr=[],rentarr=[];
                        		$(".dep").each(function(i){deparr.push($(this)[0].innerHTML);});
                        		//计算押金和
                        		var depsum=0;
                        		for(var i=0;i<deparr.length;i++){depsum+=Number(deparr[i]);}

                        		//租金数组
                        		$(".rent").each(function(i){
                        			rentarr.push($(this)[0].innerHTML);
                        		});
                        		//计算租金和
                        		var rentsum=0;
                        		for(var i=0;i<rentarr.length;i++){rentsum+=Number(rentarr[i]);}
                                var totalPrice=Number(depsum+rentsum).toFixed(2);
                        		//console.log(totalPrice)
                        		//把总额放入标签中
                        		$(".all-price").html(totalPrice);
                        })

                    } else { //柜子已满
                         /*STORERNOECOUNDS = true;*/
                        $(".sele-case").css("display","none");
                        $("#takeAbnormal").css("display","flex");
                        $("#takeAbnormal>#takeAbnormal_img").attr("src","/htmlFive/common/images/full.png");
                        $('#takeAbnormal_font').addClass("offlineFont");
                        $("#takeAbnormal #takeAbnormal_font_val").html("设备已满，请另选其他设备扫码租箱^_^");
                    }

                } else if (resMsg.data.displaySign == 'takes') {                 // 取列表渲染
                    console.log("resMsg:",resMsg);

                }else{
                    $.alert("查询异常");
                    console.log(resMsg);
                }
            } else if (resMsg.err_code == '8002') {               // 8002 设备断网
                $.hideLoading();
                OFFLINE = true;
                // $('#storeAbnormal_img').addClass("abnormalImg");
                // $("#storeAbnormal_img").attr("src","/htmlFive/common/images/tnlOffline.png");
                // $('#storeAbnormal_font').addClass("offlineFont");
                // $('#storeAbnormal_font_val').append("设备离线,请联系管理员或选择其他设备^_^");

                $('#takeAbnormal_img').addClass("abnormalImg");
                $("#takeAbnormal_img").attr("src","/htmlFive/common/images/tnlOffline.png");
                $('#takeAbnormal_font').addClass("offlineFont");
                $('#takeAbnormal_font_val').append("设备离线,请联系管理员或选择其他设备^_^");

                $(".sele-case").css("display","none");
                $("#takeAbnormal").css("display","flex");

            }else if(resMsg.err_code =="-1"){
                $.hideLoading();
                // $('#storeAbnormal_img').addClass("abnormalImg");
                // $("#storeAbnormal_img").attr("src","/htmlFive/common/images/tnlOffline.png");
                // $('#storeAbnormal_font').addClass("offlineFont");
                // $('#storeAbnormal_font_val').append("设备不存在,请联系管理员或选择其他设备^_^");

                $('#takeAbnormal_img').addClass("abnormalImg");
                $("#takeAbnormal_img").attr("src","/htmlFive/common/images/tnlOffline.png");
                $('#takeAbnormal_font').addClass("offlineFont");
                $('#takeAbnormal_font_val').append("设备不存在,请联系管理员或选择其他设备^_^");

                $(".sele-case").css("display","none");
                $("#takeAbnormal").css("display","flex");
            } else {
                $.hideLoading();
                $.alert({
                    title: '错误提示',
                    text: '未知异常',
                    onOK: function () {
                         window.history.back();
                        //window.location.reload(); //刷新当前页面
                    }
                });
            }

    $.toast.prototype.defaults.duration=1600;

    $('.sele-phone').val(sessionStorage.getItem("userphone"));

});




$('.sele-phone').blur(function () {  //ios页面被顶上去下不来
        console.log('ios_input');
        var currentPosition,timer;
        var speed=1;//页面滚动距离
        timer=setInterval(function(){
            currentPosition=document.documentElement.scrollTop || document.body.scrollTop;
            currentPosition-=speed;
            window.scrollTo(0,currentPosition);//页面向上滚动
            currentPosition+=speed; //speed变量
            window.scrollTo(0,currentPosition);//页面向下滚动
            clearInterval(timer);
        },1);

});





// var htmlScrollHeight;
// $('.sele-phone').on('focus', function () {
//     htmlScrollHeight = $(document).scrollTop();
// });
// $('.sele-phone').on('blur', function () {
//     console.log('pppp');
//     $('html,body').animate({scrollTop:htmlScrollHeight}, 100);
//
// });



// var sT;
// $('input , textarea').on('focus',function(){
//     sT = document.documentElement.scrollTop || document.body.scrollTop;
// });
// $('input , textarea').on('blur',function(){
//     // window.scrollTo(0,0);
//     console.log('9999');
//     window.scrollTo(0,sT);
// });



//切换
function toggPay(){
		//console.log(PREPAYMENTTYPE)

	  var numarr=[]; //按顺序把选择的每一种柜子的数量存入数组
	  $(".reserve-num").each(function(){
		  numarr.push($(this).val())
	  });
	 
	  var lsmall=numarr[0];
	  var small=numarr[1];
	  var modille=numarr[2];
	  var large=numarr[3];
	  var llarge=numarr[4];

	var zeronum=0;
	for(var i=0;i<numarr.length;i++){
		if(numarr[i]==0){
			zeronum++;
		}
	}
  if(zeronum==numarr.length){ //如果0的数量等于numarr的长度，就是一个柜子都没选
	  $.toast('请选择箱门',"text");
  }else if($('.sele-phone').val().length==0) {
      $.toast('请输入手机号码', 'text')
  }else if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(Number($('.sele-phone').val())))){
	  $.toast('手机号码格式不正确','text')
  }else{

    var userphone=$('.sele-phone').val();
    advOrder(userphone,lsmall,small,modille,large,llarge);  //调用函数，创建预定单并发往后台
    var deparr=[],rentarr=[];
	$(".dep").each(function(i){
		deparr.push($(this)[0].innerHTML);	
	});
		//console.log(deparr);
	$(".rent").each(function(i){
		rentarr.push($(this)[0].innerHTML);	
	});

	var selenews=[{type:"超小箱",num:numarr[0],dep:deparr[0],rent:rentarr[0]},
	         {type:"小箱",num:numarr[1],dep:deparr[1],rent:rentarr[1]},
	         {type:"中箱",num:numarr[2],dep:deparr[2],rent:rentarr[2]},
	         {type:"大箱",num:numarr[3],dep:deparr[3],rent:rentarr[3]},
	         {type:"超大箱",num:numarr[4],dep:deparr[4],rent:rentarr[4]}];

	//console.log(selenews);
	for(var j=selenews.length-1;j>=0;j--){//删除选择数量为0的类型
		if(selenews[j].num==0){
			selenews.splice(j,1);
		}
	}
	//展示支付信息
	var html='';
	for(var i=0;i<selenews.length;i++){	
		html+="<div>" +
                 "<div class='seled_type' >"+selenews[i].type+"</div>" +
                 "<div class='seled_number'>x<span>"+selenews[i].num+" </span> </div>" +
                 "<div class='seled_price'> 押金:<span>￥"+selenews[i].dep+"</span>租金: <span>￥"+selenews[i].rent+"</span>" + "</div>" +
              "</div>";
	}
	  $('.seled-data').html(html);
	  $(".seled-phone").html($(".sele-phone").val());
	  $(".seled-all-price").html('￥'+$(".all-price").html());
  }
	
}






function payed(){ //下单
    console.log(PREPAYMENTTYPE);
    console.log(STORECHARGE_PACKAGEID)
	var userphone=$('.seled-phone').html();
    var amt=$('.all-price').html();
    amt=Number(amt)*100;
    $.showLoading("请稍等...");
    if(PREPAYMENTTYPE==0){// 免费模式0-创建订单并跳转到开箱
          $.ajax({
              type: 'post',
              url: '../../../storeControles',
              dataType: 'json',
              async:false,  //同步
              data: {
                  "openid": OPENID,
                  "terminalid":TERMINALID,
                  "packageid":STORECHARGE_PACKAGEID,
                  "telephone":userphone,
                  "prepaymenttype":PREPAYMENTTYPE ,           //收费模式,此处为0
                  "types": "createOrder"
              },
              contentType: 'application/x-www-form-urlencoded',
              success: function (res) {
                  console.log(res);
                  if(res.err_code==0){
                      $.hideLoading();
                      window.location.href="/htmlFive/weixin/takees.jsp?terminalid="+TERMINALID+"&openid="+OPENID+"&dealerName="+DEALERNAME+"&terminalName="+TERMINALNAME+"&timestamp="+1000+"&flag="+FLAG+"&sex="+SEXAREA+"";
                  }else{
                      $.hideLoading();
                      $.toast('租柜失败，请重试！','text');
                      setTimeout(function () {
                            window.location.reload();
                      },1600)
                  }
                },
              error:function(){
                  console.log('error');
                  window.location.reload();
              }
          })
      }else{
            $.modal({
                title: "温馨提示",
                text:"请确认支付",
                buttons: [
                    { text: "取消", className: "default",onClick: function(){$.hideLoading(); }},
                    { text: "确认",onClick: function() {
                            $.hideLoading();
                                var urls= "../payUrl.jsp?terminalid=" + TERMINALID
                                    +"&openid="             + OPENID
                                    +"&dealerName="         + DEALERNAME
                                    +"&terminalName="       + TERMINALNAME
                                    +"&packageid="          + STORECHARGE_PACKAGEID
                                    +"&tradewaterno="       + STORECHARGE_PACKAGEID
                                    +"&types=storePay&amt=" + amt
                                    +"&prepaymenttype="     + PREPAYMENTTYPE
                                    +"&flag="                +FLAG
                                    +"&sex="                +SEXAREA;
                                window.location.href =urls;
                        }
                    }]

            });
      }

}


function createOrder(userphone) { //创建订单 --免费付费同一个
    var result;
    $.ajax({
        type: 'post',
        url: '../../../storeControles',
        dataType: 'json',
        async: false,  //同步
        data: {
            "openid": OPENID,
            "terminalid": TERMINALID,
            "packageid": STORECHARGE_PACKAGEID,
            "telephone": userphone,
            "prepaymenttype": PREPAYMENTTYPE,           //收费模式,此处为0
            "types": "createOrder"
        },
        contentType: 'application/x-www-form-urlencoded',
        success: function (res) {
            result=res;
        },
        error: function () {
            console.log('err');
            window.location.reload();
        }
    })
    return result;

}

//返回选柜页面，并删除预定单
function backSel(){
    $.ajax({
        type: 'post',
        dataType: 'json',
        url: '../../../storeControles',
        data: {"terminalid":    TERMINALID,
            "openid":        OPENID,
            "packageid":     STORECHARGE_PACKAGEID,
            "findtypes":     2,  //查询类型   1:交易流水号  2:订单号
            "flag":           1,
            "sex":             1,
            "types": "updateOrderpre"},      // 清除预订单
        contentType: 'application/x-www-form-urlencoded',
        success: function(res){
            // console.log(res);
            $('.sele-case').css({display:'block'});
            $('.seled-pay').css({display:'none'});
            clearInterval(CountDown.timer);
            //window.location.reload();

        }
    })

}



//创建预订单
function advOrder(userphone,lsmall,small,modille,large,llarge) {
    $.showLoading("请稍等...");
    $.ajax({
        type: 'post',
        url: '../../../storeControles',
        dataType: 'json',
        //async:false,  //同步
        data: {
            "openid": OPENID,
            "terminalid": TERMINALID,
            "phone":    userphone,
            "lsnumber": lsmall,
            "snumber": small,
            "mnumber": modille,
            "lnumber": large,
            "llnumber": llarge,
            "flag":           FLAG,
            "sex":             SEXAREA,
            "servicetype":  3,
            "types": "createPreOrder"
        },
        contentType: 'application/x-www-form-urlencoded',
        success: function (res) {

            //console.log(res);
            if (res.data.state=="0"){
                $.hideLoading();
            	$('.sele-case').css({display:'none'});
            	$('.seled-pay').css({display:'block'});

                CountDown.do();

                STORECHARGE_PACKAGEID = res.data.packageid;
                sessionStorage.setItem("userphone",userphone);
            }else {
                $.hideLoading();
                $.alert(res.data.memo);
            }
        },
        error:function () {
            console.log('err');
            window.location.reload();
        }
    });
}





var CountDown = {
    timer:null,
    do:function(){
        var that=this;
        var maxtime=120;
        if(that.timer){//有定时器就清除
            clearInterval(this.timer);
            $('.del-time').html('');
        }
        that.timer = setInterval(function () {
           // console.log(maxtime);
           // var minutes = Math.floor(maxtime / 60);
           // var seconds = Math.floor(maxtime % 60);
            var msg = '倒计时: '+maxtime + "秒";
            $('.del-time').html(msg);
            if (maxtime> 0) {
                maxtime--;
            } else {
                clearInterval(that.timer);
                backSel();
            }
        },1000);
    }
};



// function explain(){ //说明书
//     console.log('说明书');
//     $("#explain").popup();
//
// }


//方法2 ，需要在返回（删除预订单）-->clearTimeout(timer); maxtime=16;

// var maxtime = 16;
// var timer;
// function CountDown() {  //11
//
//     var minutes =Math.floor(maxtime / 60);
//     var seconds =Math.floor(maxtime % 60);
//     var msg = "倒计时: " +'0'+ minutes + "分" + seconds + "秒";
//
//     $('.del-time').html(msg);
//     if (maxtime > 0) {
//             maxtime--;
//     }else{
//        clearTimeout(timer);
//         backSel();
//     }
//
//     timer=setTimeout("CountDown()",1000);
// }











/** 提取数组类型*/
function arr(arr){
    var newarr = new Array();
    for(var i = 0; i < arr.length; i++){    //循环遍历当前数组
        // 判断当前数组下标为i的元素是否已经保存到临时数组
        // 如果已保存，则跳过，否则将此元素保存到临时数组中
        if(newarr.indexOf(arr[i]) == -1){
            newarr.push(arr[i]);
        }
    }
    return newarr;
}




/* 返回刷新 */
function pushHistory(){
    window.addEventListener("popstate", function(e) {
        self.location.reload();
    }, false);
    var state = {
        title : "",
        url : "#"
    };
    window.history.replaceState(state, "", "#");  //插入一个新的历史记录
}

/*  Swiper顶部广告样式控制 */
var mySwiper = new Swiper ('#top_ad', {
    loop: true, // 循环模式选项
    autoplay: true,
    pagination: {
        el: '.swiper-pagination',
        hideOnClick :true,
        renderBullet: function (index, className) {
            return '<span class="' + className + '"></span>';
        },
    },
});

/* Swiper页面底部存取菜单按钮触发动作 */
var STmodalChoose = new Swiper('#STmodalChoose');




 var flag=getUrlParam('flag');
//console.log(flag);
if(flag==1){//预约

    $('#btn_store').click(function(){
    	self.location.reload();
    });
    // $('#btn_store').click(throttle(btnStores));

    $('#btn_take').click(de(btnTakes));
}else if(flag==2){//非预约
    $('#btn_store').click(function(){
    	self.location.reload();
    });
    // $('#btn_store').click(throttle(btnStore));
    $('#btn_take').click(de(btnTake));
}




